<template>
    <div class="_message_list">
        <div class="_self_message_item">
            <div class="_head"></div>
            <div class="_msg_body">{{props.message.prompt}}</div>
        </div>
        <div class="_message_item">
            <div class="_head"></div>
            <div class="_msg_body" :class="status" v-html="gptTextTrans(props.message.repeat + flicker)"></div>
        </div>
    </div>
</template>
<script setup>
import {gptTextTrans} from '@frontend/utils/utils'
const props = defineProps(['message', 'status'])
const flicker = "<span class='flicker'></span>"

</script>

<style lang="scss">
._message_list{
    font-size:0.8rem;
    max-width:800px;
    ._message_item{
        padding:10px;
        display: flex;
        ._head{
            width:30px;
            height:30px;
            min-width: 30px;
            border-radius: 15px;
            background-color: #84e1b9;
        }
        ._msg_body {
            flex-grow: 1;
            padding: 8px;
            margin-left: 16px;
            background-color: $cbg-color;
            border-radius: 8px;
            /* border: 1px solid #2a2a2a; */
            // box-shadow: -1px -1px $bd-color-active, 1px 1px #121212;
            .flicker{
                display: none;
                border-left: 3px solid #fff;
                height: 0.8rem;
                vertical-align: middle;
                margin-top: -4px;
                will-change: opacity, transform;
                animation: bounce 0.4s linear infinite;
                margin-left: 4px;
            }
            &.running{
                .flicker{
                    display: inline-block;
                }
            }
        }
    }
    ._self_message_item{
        padding: 0 10px 0 10px;
        display: flex;
        ._head{
            width:30px;
            height:30px;
            border-radius: 15px;
            background-color: black;
        }
        ._msg_body{
            flex-grow: 1;
            margin-left: 16px;
        }
    }
    @keyframes bounce {
        0% {
          opacity: 0;
          transform: scale(0.8);
        }
        50% {
          opacity: 1;
          transform: scale(1);
        }
        100% {
          opacity: 0;
          transform: scale(0.8);
        }
    }
}
</style>